package com.lxy.auth.config;

import com.lxy.auth.dto.UserDto;
import com.lxy.auth.utils.JWTUtil;
import com.lxy.common.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@Slf4j
public class UserInterceptor implements HandlerInterceptor {

/*    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String token = request.getHeader("token");
        if (!StringUtils.isBlank(token)) {
            UserDto dto = JWTUtil.verifyAndGetUser(token);
            if (dto != null) {
            }else {
                log.error("token 验证失败！token is {}, uri is {}", token, request.getRequestURI());
                throw new ApiException(AppCode.TOKEN_ERROR, "token 校验不通过！");
            }
        }
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }*/
}
